const APIUrl = require('../../../../tools/APIurl');
const mAPIUrl = new APIUrl()
var that;
Page({

    /**
     * 页面的初始数据
     */
    data: {
        itemList: [{
                right_text: "请选择",
                text: "楼层",
                show: false,
                events: ""
            },
            {
                right_text: "请选择",
                text: "户型",
                show: false,
                events: ""
            },
            {
                right_text: "请选择",
                text: "使用面积",
                show: false,
                events: ""
            },
            {
                right_text: "请选择",
                text: "装修情况",
                show: false,
                events: "",
            },
            {
                right_text: "请选择",
                text: "房屋配置",
                show: true,
                events: ""
            },
        ],
        changeSex: true,
        manClass: "changeSex_item_man",
        womanClass: "changeSex_item_woman_select",
        gender: 0,
        info: [{
                title: '房号',
                content: '请输入房号',
                events: 'bindRoom'
            }, {
                title: '户型',
                content: '请输入户型',
                events: 'bindDoors'
            }, {
                title: '面积',
                content: '请输入面积',
                events: 'bindArea'
            }, {
                title: '朝向',
                content: '请输入朝向',
                events: 'bindToward'
            }, {
                title: '家具',
                content: '请输入家具',
                events: 'bindGoodfurniture'
            }, {
                title: '照片',
                content: '请输入照片',
                events: 'bindImage'
            },

        ],
        address:'',
        address_id:0,
        RSaddress:[{
            address_id:0,
            user_id:wx.getStorageSync('userInfo').id,
            Room_number:'',
            type:false,
            doors:'',
            area:'',
            toward:'',
            goodfurniture:'',
            image:'',
        }],
    },
    bindRoom(e){
        var RSaddress = that.data.RSaddress
        RSaddress[0].Room_number=e.detail.value
        that.setData({
            RSaddress:RSaddress
        })
    },
    bindDoors(e){
        var RSaddress = that.data.RSaddress
        RSaddress[0].doors=e.detail.value
        that.setData({
            RSaddress:RSaddress
        })
    },
    bindArea(e){
        var RSaddress = that.data.RSaddress
        RSaddress[0].area=e.detail.value
        that.setData({
            RSaddress:RSaddress
        })
    },
    bindToward(e){
        var RSaddress = that.data.RSaddress
        RSaddress[0].toward=e.detail.value
        that.setData({
            RSaddress:RSaddress
        })
    },
    bindGoodfurniture(e){
        var RSaddress = that.data.RSaddress
        RSaddress[0].goodfurniture=e.detail.value
        that.setData({
            RSaddress:RSaddress
        })
    },
    bindImage(e){
        var RSaddress = that.data.RSaddress
        RSaddress[0].image=e.detail.value
        that.setData({
            RSaddress:RSaddress
        })
        console.log(that.data.RSaddress)
    },
    onLoad: function (options) {
        that = this
        console.log(options)
        var RSaddress= that.data.RSaddress
        RSaddress[0].address_id=options.address_id
        that.setData({
            address:options.address,
            RSaddress:RSaddress
        })
    },
    save(){
        mAPIUrl.update('/api/mgr/rsAddress',{
            action:'add',
            data: {
                address_id: that.data.RSaddress[0].address_id,
                user_id: wx.getStorageSync('userInfo').id,
                Room_number: that.data.RSaddress[0].Room_number,
                doors: that.data.RSaddress[0].doors,
                area: that.data.RSaddress[0].area,
                toward: that.data.RSaddress[0].toward,
                goodfurniture: that.data.RSaddress[0].goodfurniture,
                image: that.data.RSaddress[0].image,
            }
          },function(res){
            console.log(res)
            wx.navigateBack({
              delta: 0,
            })
          })

    },
})